<template>
  <div class="search">
    <div class="form form-inline">
      <select class="form-control" v-model="search.bqaid">
        <option value="">买方问答的id</option>
        <option v-for="i in buyerList" :value="i.id">{{i.id}}-{{i.name}}</option>
      </select>
      <input type="text" class="form-control input-sm" placeholder="标题关键字" v-model="search.keyword">
      <button class="btn btn-sm btn-primary" @click.prev="searchList">搜索</button>
    </div>
  </div>
  <table v-show="list && list.length > 0" class="table table-bordered table-hover">
    <caption>投研大咖说资料</caption>
    <thead>
      <tr>
        <th class="col-xs-1">ID</th>
        <th class="col-xs-1">标题</th>
        <th class="col-xs-1">时间</th>
        <th class="col-xs-1">主讲人</th>
        <!-- <th class="col-xs-1">音频</th> -->
        <th class="col-xs-1">附件</th>
        <th class="col-xs-1"></th>
      </tr>
    </thead>
    <tbody>
      <tr v-for="it in list">
        <td>
          {{it.id}}
        </td>
        <td>
          {{it.title}}
        </td>
        <td>
          {{it.pubDate | timeToString}}
        </td>
        <td>
          {{it.speakerInfos && it.speakerInfos[0].speaker}}
        </td>
        <!-- <td>
          <a :href="item.voiceUrl" target="_blank">试听</a>
        </td> -->
        <td>
          <div v-if="it.attachments">
            <a class="attachment" v-for="attachment in it.attachments" :href="attachment.url" target="_blank">{{attachment.name}}</a>
          </div>
        </td>
        <td class="col-nowrap text-right">
          <button class="btn btn-sm btn-primary" @click="updateItem(it)">修改信息</button>
          <button class="btn btn-sm btn-primary" @click="showUploader(it.id)">上传附件</button>
          <button class="btn btn-sm btn-danger" @click="deleteItem(it.id)">删除</button>
        </td>
      </tr>
    </tbody>
  </table>
  <vue-pages :pages.sync="pages" :get-list="getList"></vue-pages>
  <vue-uploader v-ref:uploader></vue-uploader>
</template>
<style src="./item-list.css" scoped></style>
<script src="./item-list.js"></script>